# urllib中的一个类和6个方法
import urllib.request

url = 'http://www.baidu.com'

response = urllib.request.urlopen(url)
# <class 'http.client.HTTPResponse'>
# print(type(response))

# 读取6个字节
# content = response.read(6)
# print(content)

# 读取一行
# content = response.readline()
# print(content)

# 获取http状态码 200
# print(response.getcode())

# 获取返回的url地址
# print(response.geturl())

# 获取头信息
print(response.getheaders())
